<template>
  <view class="main">
    <view class="title">进入条码后台管理请输入有效的管理员验证码</view>
    <view class="item" @tap='KeyboarOpen'>
      <password-input :numLng='password'></password-input>
    </view>
    <number-keyboard tabBar ref='KeyboarHid' @input='inpval' psdLength='6'></number-keyboard>
  </view>
</template>
<script>
  import numberKeyboard from '@/components/number-keyboard/number-keyboard.vue'
  import passwordInput from '@/components/password-input/password-input.vue'
  export default {
    components: {
      numberKeyboard,
      passwordInput
    },
    data() {
      return {
		  id:0,//判断从哪个页面进来1配置表，2临时表
        password: "", //输入的内容
      }
    },
    onLoad(e) {
	this.id=e.id;
      //因为此时实例没有挂载完成，需要延迟操作
      setTimeout(() => {
        this.$refs.KeyboarHid.open()
      }, 50)
	  	uni.setNavigationBarColor({
	  		frontColor: "#ffffff",	//文字颜色
	  		backgroundColor: this.$kdup.color	//底部背景色
	  	})
    },
    methods: {
      //打开键盘
      KeyboarOpen(e) {
        this.$refs.KeyboarHid.open();
      },
      // //输入的值
      inpval(val) {
        this.password = val;
		if(val.length==6){
			if(val==666666){//这里是正确验证密码
			uni.showToast({
				icon: 'none',
				title: '验证成功',
				duration: 3000
			});	
			if(this.id==1){//跳入配置表
				uni.navigateTo({
					 url:'/pages/BarcodeConfig/BarcodeConfig'
				})
			}else if(this.id==2){//跳入临时表
				uni.navigateTo({
					 url:'/pages/LineMenu/LineMenu'
				})
			}
			}else{
			  this.$refs.KeyboarHid.reset();
			uni.showToast({
				icon: 'none',
				title: '验证码错误！',
				duration: 3000
			});
		}
		}
      }
    }
  }
</script>
<style scoped>
  .main {
    padding: 0rpx 40rpx;
  }
  .ipt {
    border-bottom: 1rpx solid #CCCCCC;
  }
  .item {
    padding: 10rpx 0rpx;
  }
  .title {
    margin: 30rpx 0;
  }
</style>